var webpack = require('webpack'),
    path = require("path");

module.exports = {
 
    entry:  {
        app:"./src/app.js", 
        lib:["react","director"]
    },

    output: {
        //path: __dirname,
        path: path.resolve("./dist/"),
        publicPath: "./dist/",
        filename: "bundle.js",
        //chunkFilename: '[name].js'
    },

    plugins: [
　　　　 //合并lib里的库为独立的文件
        new webpack.optimize.CommonsChunkPlugin({
            name:"lib",
            filename:"lib.bundle.js",
        }),
        //每个模块自动载入
        new webpack.ProvidePlugin({
            config : './config.js',
            React : 'react',
            $: "jquery",
            _: "lodash"
        }),

        //全局常量,也可以配置到config.js里
        new webpack.DefinePlugin({
            version: '1.0',
            debug: true,
        })

    ],


    module: {
        /* 
        loaders: [{
            test: /\.js$/,
            loader: 'babel-loader'
        }, {
            test: /\.jsx$/,
            loader: 'babel-loader!jsx-loader?harmony'
        }]
        */    
        loaders: [     
           { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
           //不能使用es6的import语法才行
           //{ test: /\.js$/, loader: "imports?this=>window"},
           { test: /\.css$/, loader: 'style-loader!css-loader' },
           { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'}
        ]
    }
};
